-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Rename expose_addr to expose_provenance
#122964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to the platform-builtins intrinsics. Make sure the cc @antoyo, @GuillaumeGomez, @bjorn3, @calebzulawski, @programmerjake This PR changes Stable MIR cc @oli-obk, @celinval, @ouz-a Portable SIMD is developed in its own repository. If possible, consider making this change to rust-lang/portable-simd instead. cc @calebzulawski, @programmerjake This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
This comment has been minimized.
This comment has been minimized.
I don't see how that implication would be any stronger by saying The main benefit of |
|
The Miri subtree was changed cc @rust-lang/miri |
|
|
||
| let val = match *kind { | ||
| mir::CastKind::PointerExposeAddress => { | ||
| mir::CastKind::PointerExpose => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW in MiniRust I got rid of this "expose cast", and instead made expose something more like a NonDivergingIntrinsic. That properly reflects that it is entirely decoupled. But ofc that is hard to translate to LLVM...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmh, actually... Since currently we generate ptrtoint for every conversion, including addr, we might be able to add a new intrinsic for exposing that lowers to a noop in LLVM, but can get recognized in miri, and then write expose as
intrinsics::expose(ptr);
ptr.addr()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since currently we generate ptrtoint for every conversion, including addr
Not anymore: #121282.
EDIT: Ah no that's the other direction. Still, this is not something I'd like to rely on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we could indeed make it an intrinsic. As a cast it is kind of an odd duck, none of our other casts has a side-effect. All other casts can be removed when their result is unused.
compiler/stable_mir/src/mir/body.rs
Outdated
| #[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
| pub enum CastKind { | ||
| PointerExposeAddress, | ||
| PointerExpose, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't rename it here. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then where should we put the note to rename it in the future? It's quite annoying when we clean up naming but smir still uses old (and thus more confusing / less apt) names possibly indefinitely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the field instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's just a comment it will get lost. It needs to carry at least some sort of marker so that when you eventually do follow suit and fix old confusing names in smir, you can reliably find them. Something one can grep for. Like FIXME(smir-rename) or so -- I don't care about the details, but I hope the smir team can come up with a plausible process and document it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment with FIXME(smir-rename). And just fyi, #122935 made this kind of change but didn't get caught 😄.
|
We discussed this in the libs-api meeting and we prefer |
|
☔ The latest upstream changes (presumably #123396) made this pull request unmergeable. Please resolve the merge conflicts. |
expose_addr to exposeexpose_addr to expose_provenance
This comment has been minimized.
This comment has been minimized.
|
I have updated the PR description to match, feel free to tweak it further. |
|
@bors r+ |
expose_addris a bad name, an address is just a number and cannot be exposed. The operation is actually about the provenance of the pointer.This PR thus changes the name of the method to
expose_provenancewithout changing its return type. There is sufficient precedence for returning a useful value from an operation that does something else without the name indicating such, e.g.Option::insertandMaybeUninit::write.Returning the address is merely convenient, not a fundamental part of the operation. This is implied by the fact that integers do not have provenance since
must behave exactly like
as the result of
ptr.expose_provenance()andptr.addr()is the same integer. Therefore, this PR removes the#[must_use]annotation on the function and updates the documentation to reflect the important part.An alternative name would beexpose_provenance. I'm not at all opposed to that, but it makes a stronger implication than we might want that the provenance of the pointer returned byptr::with_exposed_provenance1 is the same as that what was exposed, which is not yet specified as such IIUC. IMHOexposedoes not make that connection.A previous version of this PR suggested
exposeas name, libs-api decided onexpose_provenanceto keep the symmetry withwith_exposed_provenance.CC @RalfJung
r? libs-api
Footnotes
I'm using the new name for
from_exposed_addrsuggested by rename ptr::from_exposed_addr -> ptr::with_exposed_provenance #122935 here. ↩